/*
 * Copyright (c) 2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Constants for breakpoint.
 */
export class BreakpointConstants {
  /**
   * Breakpoints that represent small device types.
   * 小于等于DEVICE_WIDTH_MIDDLE
   */
  static readonly BREAKPOINT_SM: string = 'sm';

  /**
   * Breakpoints that represent middle device types.
   * 大于DEVICE_WIDTH_MIDDLE，小于DEVICE_WIDTH_LARGE
   */
  static readonly BREAKPOINT_MD: string = 'md';

  /**
   * Breakpoints that represent large device types.
   * 大于等于DEVICE_WIDTH_LARGE
   */
  static readonly BREAKPOINT_LG: string = 'lg';

  // /**
  //  * SMALL device width.
  //  */
  // static readonly SMALL_DEVICE_WIDTH: number = 320;

  /**
   * Middle device width.
   */
  static readonly DEVICE_WIDTH_MIDDLE: number = 520;

  /**
   * Large device width.
   */
  static readonly DEVICE_WIDTH_LARGE: number = 840;

  /**
   * Full percent.
   */
  static readonly FULL_PERCENT: string = '100%';

  static readonly DEVICE_TYPES: string[] = ['2in1', 'tablet', 'phone'];

  static readonly AppStoreKey_CurrentBreakpoint = "currentBreakpoint";
  static readonly AppStoreKey_ScreenHeight = "screenHeight";
  static readonly AppStoreKey_ScreenWidth = "screenWidth";

}
export enum BreakpointTypeEnum {
  SM = 'sm',
  MD = 'md',
  LG = 'lg',
}

export interface BreakpointTypes<T> {
  sm: T;
  md: T;
  lg: T;
}

export class BreakpointType<T> {
  sm: T;
  md: T;
  lg: T;

  constructor(param: BreakpointTypes<T>) {
    this.sm = param.sm;
    this.md = param.md;
    this.lg = param.lg;
  }

  getValue(currentBreakpoint: string): T {
    if (currentBreakpoint === BreakpointTypeEnum.SM) {
      return this.sm;
    }
    if (currentBreakpoint === BreakpointTypeEnum.MD) {
      return this.md;
    }
    return this.lg;
  }

}